<!--
    车辆信息（单辆车） 公共插件
        参数：对象类型
        Obj: {
                contractNo: 合同号,
                roleType: 角色类型,（枚举类型：经销商:SP ）
            }
-->
<style>
    /* @import "../../../styles/common/basic-info.css"; */
</style>
<template>
    <div class="asset-info" style="width: 100%;">
        <Form class ref="assetForm" :model="assetForm" :label-width="100">
            <Row>
                <Col v-show="type !== 'insurance'" :xs="24" :md="12" :xl="6">
                    <FormItem label="款式名称">
                        <Tooltip max-width="250" :content="assetForm.styleName" placement="top" theme="light">
                            <Input type="text" v-model="assetForm.styleName" disabled/>
                        </Tooltip>
                    </FormItem>
                </Col>
                <Col v-show="type !== 'insurance'" :xs="24" :md="12" :xl="6">
                    <FormItem label="车型名称">
                        <Tooltip max-width="250" :content="assetForm.modelName" placement="top" theme="light">
                            <Input type="text" v-model="assetForm.modelName" disabled/>
                        </Tooltip>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="品牌名称">
                        <Input type="text" v-model="assetForm.brandName" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="车牌号码">
                        <Input type="text" v-model="assetForm.licensePlate" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="车辆属性">
                        <Select v-model="assetForm.carNature" style="min-width:200px" disabled placeholder="车辆属性">
                            <Option v-for="item in dataDic.carNature" :value="item.value" :label="item.title"
                                    :key="item.value">{{ item.title }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col v-show="type !== 'insurance' && type !== 'cancelContract'" :xs="24" :md="12" :xl="6">
                    <FormItem label="车辆种类">
                        <Select v-model="assetForm.carKind" style="min-width:200px" disabled placeholder="车辆种类">
                            <Option v-for="item in dataDic.carType" :value="item.value" :label="item.title"
                                    :key="item.value">{{ item.title }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="VIN号">
                        <Input type="text" v-model="assetForm.carVin" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="发动机号">
                        <Input type="text" v-model="assetForm.engineNo" disabled/>
                    </FormItem>
                </Col>
                <Col v-show="type !== 'insurance'" :xs="24" :md="12" :xl="6">
                    <FormItem label="车辆型号">
                        <Input type="text" v-model="assetForm.fullModelNum" disabled/>
                    </FormItem>
                </Col>
                <Col v-if="type !== 'cancelContract'" :xs="24" :md="12" :xl="6">
                    <FormItem label="车辆用途">
                        <Select v-model="assetForm.carUse" style="min-width:200px" disabled placeholder="车辆用途">
                            <Option v-for="item in dataDic.carFunction" :value="item.value" :label="item.title"
                                    :key="item.value">{{ item.title }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
            </Row>
        </Form>
    </div>
</template>
<script>
    import {getCustAssetInfo} from "_p/basic/api/contract/common/cust-asset/cust-asset";
    import {getByTypes} from "_p/basic/api/admin/datadic";
    import {deepClone} from "@/libs/utils/ObjectClone";
    import {channelType} from "_p/basic/api/contract/channel-type/channel-type";

    export default {
        props: {
            Obj: {
                type: Object
            },
            type: {
                type: String
            },
        },
        data() {
            return {
                dataDic: {},
                assetForm: {},
                dicKeys: ["carType", "carNature", "carFunction"]
            };
        },
        methods: {
            init() {
                this.getCustAssetInfo();
            },
            getCustAssetInfo() {
                getCustAssetInfo(this.Obj.contractNo, channelType(this.$route.meta.params)).then(res => {
                    if (res.code === "0000") {
                        this.assetForm = deepClone(res.data.Asset);
                    }
                });
            },
            initDataDic() {
                let self = this;
                getByTypes(this.dicKeys).then(res => {
                    if (res.code === "0000" && res.data) {
                        self.dataDic = res.data;
                    }
                });
            }
        },
        mounted() {
            this.initDataDic();
            this.init();
        }
    };
</script>
<style scoped>
    .asset-info >>> .ivu-input[disabled] {
        color: black;
    }
    .asset-info >>> .ivu-select-disabled[disabled] {
        color: black;
    }
    .asset-info >>> .ivu-select-disabled .ivu-select-selected-value {
        color: #515a6e;
    }

    .asset-info >>> .ivu-input-number-input[disabled] {
        color: black;
    }
</style>
